@echo off
setlocal

echo Building KeyAuthCore DLL...

:: 创建build目录（如果不存在）
if not exist "build" mkdir "build"

:: 设置环境变量
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=1

echo Environment variables set, starting build...

:: 编译DLL
go build -x -o "build\keyauthcore.dll" -buildmode=c-shared

:: 检查编译结果
if %errorlevel% neq 0 (
    echo Failed to build KeyAuthCore DLL with error code %errorlevel%
    exit /b %errorlevel%
)

:: 复制头文件到build目录
copy /Y "keyauthcore.h" "build\"
if %errorlevel% neq 0 (
    echo Failed to copy header file with error code %errorlevel%
    exit /b %errorlevel%
)

echo Build completed successfully. Files are in the build directory.
echo DLL: build\keyauthcore.dll
echo Header: build\keyauthcore.h

endlocal 